﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WISD.CarFriend.BLL.Web;

namespace WISD.CarFriend.Web.Admin.Module.MemberRegist
{
    public partial class Edit : Utility.BasicPage
    {
        #region 字段
        private int m_Id;
        #endregion


        #region 事件
        /// <summary>
        /// Page_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] == null || !int.TryParse(Request.QueryString["id"], out this.m_Id))
            {
                base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>您要修改的信息不存在或参数不正确。", "back", "Error");
                return;
            }

            if (!IsPostBack)
            {
                // 验证权限
                base.CheckPermission("MemberRegist_Edit");

                WISD.CarFriend.Model.CFModel.T_CF_ToolTip toolTipModel
                    = ToolTipManageModule.GetModel(this.m_Id);
                if (toolTipModel != null)
                {
                    this.txtTitle.Text = toolTipModel.Title;
                    this.txtContent.Text = toolTipModel.Content;
                    FCKeditor.Value = toolTipModel.Remark;
                }
                else
                {
                    base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>您要修改的信息不存在或参数不正确。", "back", "Error");
                }
            }
        }


        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                WISD.CarFriend.Model.CFModel.T_CF_ToolTip toolTipModel
                    = ToolTipManageModule.GetModel(this.m_Id);
                toolTipModel.Content = this.txtContent.Text.Trim();
                toolTipModel.Remark = this.FCKeditor.Value.ToString().Trim();
                ToolTipManageModule.Update(toolTipModel);
                ShowMessageBox("修改成功！", "List.aspx", "Success");
            }
            catch (Exception ex)
            {
                base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>" + ex.Message.ToString(), "back", "Error");
            }
        }
        #endregion

    }
}